﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

using com.vs.DataAccess;
using com.vs.DataAccess.DO;
using com.vs.General;


namespace com.vs.Inventory.BL
{
    public class AttributeManager
    {
        public int GetAttributeNum(Session sess, string stItem, string stComp, string stAttribute1, string stAttribute2, 
            string stAttribute3, string stAttribute4, string stAttribute5, string stAttribute6, string stAttribute7, string stAttribute8)
        {
            DataHelper helper = null;
            DataTable dtModel = null;
            string stSQL = "ATR_RAttribute";

            try
            {
	            helper = new DataHelper(sess);
	            dtModel = helper.GetTable(CommandType.StoredProcedure, stSQL, new IDataParameter[] { 
				            DataHelper.BuildParameter(sess, "@ITEM", stItem),
				            DataHelper.BuildParameter(sess, "@COMPANY", stComp),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE1", stAttribute1),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE2", stAttribute2),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE3", stAttribute3),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE4", stAttribute4),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE5", stAttribute5),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE6", stAttribute6),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE7", stAttribute7),
				            DataHelper.BuildParameter(sess, "@ATTRIBUTE8", stAttribute8)
			            });
                if (DataManager.IsEmpty(dtModel))
                    return 0;
                else
                    return DataManager.GetInt(dtModel.Rows[0], 0);
            }
            catch (Exception e)
            {
	            ExceptionManager.LogException(sess, e);
	            return 0;
            }
            finally
            {
	            if (helper != null)
		            helper.Dispose();
            }

        }


    }
}
